package View;

import home.Config;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;

public class Video extends JPanel{

	private static final long serialVersionUID = 5483814085195994603L;
	
	private JPanel header = new JPanel(new FlowLayout(FlowLayout.LEFT));
	
	private JPanel content = new JPanel(new GridBagLayout());
	
	public Video(){
		
		super(new GridBagLayout());
		
		GridBagConstraints con = new GridBagConstraints();
		
		this.setHeader(header);
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 0.5;
		con.weighty = 0;
		con.gridx = 0;
		con.gridy = 0;
		this.add(header, con); 
		
		this.setContent(content);
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 0.165;
		con.weighty = 0.5;
		con.gridx = 0;
		con.gridy = 1;
		this.add(content, con);
		
	}
	
	private JPanel setHeader(JPanel panel){
		
		// custumizza l'header
		panel.setBackground(Config.getConfig().getMarrone());
		panel.setBorder(BorderFactory.createLineBorder(Color.white));
		panel.setPreferredSize(new Dimension(966, 30));
		panel.setMinimumSize(new Dimension(966, 30));
		
		// crea il primo bottone e lo aggiunge
	    JButton home = new JButton();
	    Home.f(home, "home", true);
	    panel.add(home);
	    
	    //Crea le freccie e le aggiunge
		Home.freccia(panel);
	    
		// crea il secondo bottone e lo aggiunge
	    JButton ricerca = new JButton();
	    Home.f(ricerca, "cosmetici e strumenti", true);
	    panel.add(ricerca);
	    
	    //Crea le freccie e le aggiunge
		Home.freccia(panel);
		
		// crea il secondo bottone e lo aggiunge
	    JButton risultati = new JButton();
	    Home.f(risultati, "risultati", true);
	    panel.add(risultati);
	    
	    //Crea le freccie e le aggiunge
		Home.freccia(panel);
		
		// crea il secondo bottone e lo aggiunge
	    JButton video = new JButton();
	    Home.f(video, "video", false);
	    panel.add(video);
	    
		return panel;
	}

	private JPanel setContent(JPanel panel){
		
		MediaPanel m = new MediaPanel(Clio.createURL("video/video.mpg"));
		
		GridBagConstraints con = new GridBagConstraints();
		con.fill = GridBagConstraints.BOTH;
		con.weightx = 1;
		con.weighty = 1;
		con.gridx = 0;
		con.gridy = 0;
		
		panel.add(m,con);
		return panel;
		
	}

}
